﻿//-----------------------------------------------------------------------
// <copyright file="IWorkingMemory.cs" company="tuliprules.org">
//     Copyright (c) 2010 tuplelister, tuliprules.org.
// </copyright>
// <summary>This is the IWorkingMemory interface.</summary>
//-----------------------------------------------------------------------

namespace Tulip.Rules
{
    /// <summary>
    /// Represents the working memory of a production system.
    /// </summary>
    /// <remarks>Working memory is generally implemented is an in-memory store of factTypes.</remarks>
    public interface IWorkingMemory
    {
        /// <summary>
        /// Assert a fact  to the working memory.
        /// </summary>
        /// <param name="fact">The fact to be asserted.</param>
        void Assert(object fact);

        /// <summary>
        /// Assert a collection of fact to the working memory.
        /// </summary>
        /// <param name="facts">The collection of facts to be asserted.</param>
        void Assert(object[] facts);

        /// <summary>
        /// Modify a fact in the working memory.
        /// </summary>
        /// <remarks>This overload does not support refraction.</remarks>
        void Modify();

        /// <summary>
        /// Modify a fact in the working memory.
        /// </summary>
        /// <param name="mode">The mode of modification.  This parameter can be used to control refraction and prevent looping.</param>
        void Modify(ModifyMode mode);

        /// <summary>
        /// Retract a fact from the working memory.
        /// </summary>
        /// <param name="fact">The fact to be retracted.</param>
        void Retract(object fact);

        /// <summary>
        /// Retract a collection of facts from the working memory.
        /// </summary>
        /// <param name="facts">The collection of facts to be retracted.</param>
        void Retract(object[] facts);

        /// <summary>
        /// Retract all facts of a given type from the working memory.
        /// </summary>
        /// <param name="factType">The type of facts to be retracted.</param>
        void RetractByType(System.Type factType);

        /// <summary>
        /// Retract all facts of a collection of given types from the working memory.
        /// </summary>
        /// <param name="factTypes">The collection of types of fact to be retracted.</param>
        void RetractByType(System.Type[] factTypes);

        /// <summary>
        /// Clear all fact from the the working memory.
        /// </summary>
        void Clear();
    }
}
